
	<div class="card">
		<div class="card-body">
			<div class="row text-center align-items-center">
				<div class="col right-border">
					<span class="fw-bold text-secondary">商品进货额<i class="bi bi-question-circle text-secondary" style="font-size:13px" data-bs-toggle="tooltip" data-bs-placement="top" title="进货单的应收总额"></i></span><br> 
					<span class="fs-6 fw-bold text-secondary">￥#number(sumOrder.amount??0, "#.##")</span>
				</div>
				<div class="col right-border">
					<span class="fw-bold text-secondary">进货商品数</span><br> <span class="fs-6 fw-bold text-secondary">#number(sumOrder.buy_number??0, "#.####")</span>
				</div>
				<div class="col right-border">
					<span class="fw-bold text-secondary">退货商品数</span><br> 
					<span class="fs-6 fw-bold text-warning">#number(sumOrder.reject_number??0, "#.####")</span>
				</div>
				<div class="col right-border">
					<span class="fw-bold text-secondary">退货金额</span><br> 
					<span class="fs-6 fw-bold text-warning">￥#number(sumOrder.reject_amount??0, "#.##")</span>
				</div>
			</div>
		</div>
	</div>
	
#if(page.totalPage > 1)
<div class="card card-table mt-2">
	<div class="card-body page-body">
		<div class="row align-items-center oper-list">
			<div class="col-5">
			</div>
			<div class="col">
			<div class="float-end">#@paginate(page.pageNumber, page.totalPage, "")</div>
			</div>
		</div>
	</div>
</div>
#end

<table class="table table-hover table-bordered bg-white mt-2">
	<thead>
		<tr class="table-header">
			<th>图片</th>
			<th>商品名称</th>
			<th>分类</th>
			<th>进货数量</th>
			<th>进货金额</th>
			<th>退款数量</th>
			<th>退货金额</th>
			<th style="width: 15%">操作</th>
		</tr>
	</thead>
	<tbody class="table-row" id="statPurchaseGoods-list">
		#for (x : page.list)
		#set(goodsInfo = x.goodsInfo)
		<tr data-id="#(goodsInfo.id)" id="statPurchaseGoods-data-#(goodsInfo.id)">
			<td>
			#set(mainThumb = x.mainThumb)
			#if(mainThumb)
			   <img src="#(resourceUploadDomain)#(mainThumb.thumb)" layer-src="#(resourceUploadDomain)#(mainThumb.thumb)" alt="#(x.name)" class="rounded" style="width:20px;">
			#else
			<i class="bi bi-image" style="color: #dedede;font-size:15px"></i>
			#end
			</td>
			<td><span class="fw-bold text-secondary">#(goodsInfo.name)</span></td>
			<td>#(goodsInfo.goodsCategory.name)</td>
			<td><span >#(x.buy_number??0)</span> </td>
			<td><span >#number(x.amount??0, "#.##")</span> </td>
			<td><span >#number(x.reject_number??0, "#.####")</span> </td>
			<td><span >#number(x.reject_amount??0, "#.##")</span> </td>
			<td>
				<button type="button" class="btn btn-sm sm-more btn-outline-primary" onclick="statPurchaseGoods.show(#(goodsInfo.id));">单据明细</button> 
				<button type="button" class="btn btn-sm sm-more btn-outline-primary ms-1" onclick="statPurchaseGoods.showSupplier(#(goodsInfo.id));">供应商排行</button> 
			</td>
		</tr>
		#end

	</tbody>
</table>

<script type="application/javascript">
	
$(function() {
	// 初始化bootstrap相关组件
	common.initBootstrap();
	beekit.photos("#statPurchaseGoods-list");
	// 滚动表头处理
	common.tableFixedWidth();
	common.tableFixed();
	$(".main").scroll(function() {
		common.tableFixed();
	});
	$("#statPurchaseGoods_pageNumber").val(#(page.pageNumber));
	
	$("#statPurchaseGoods-list tr").on("dblclick", function() {
		statPurchaseGoods.show($(this).attr("data-id"));
	});

});

statPurchaseGoods.show = function(goodsInfoId) {
	var goodsCategoryId = $("#statPurchaseGoods_search_goods_category_id").val();
	var startTime = $("#statPurchaseGoods_search_start_time").val();
	var endTime = $("#statPurchaseGoods_search_end_time").val();
	
	if(goodsCategoryId == undefined) {
		goodsCategoryId = "";
	}
	beekit.offcanvas("/inventory/stat/purchaseGoods/show?goods_info_id="+goodsInfoId+"&start_time="+startTime+"&end_time="+endTime+"&goods_category_id="+goodsCategoryId);
};

statPurchaseGoods.showSupplier = function(goodsInfoId) {
	var goodsCategoryId = $("#statPurchaseGoods_search_goods_category_id").val();
	var startTime = $("#statPurchaseGoods_search_start_time").val();
	var endTime = $("#statPurchaseGoods_search_end_time").val();
	
	if(goodsCategoryId == undefined) {
		goodsCategoryId = "";
	}
	beekit.offcanvas("/inventory/stat/purchaseGoods/showSupplier?goods_info_id="+goodsInfoId+"&start_time="+startTime+"&end_time="+endTime+"&goods_category_id="+goodsCategoryId);
};


</script>
